package com.miku.blog.controller;

import com.miku.blog.annotation.SystemLog;
import com.miku.blog.domain.FriendLink;
import com.miku.blog.domain.pojo.ResponseResult;
import com.miku.blog.service.FriendLinkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author shkstart
 * @create ${}YEAR-06-03 15:30
 */
@Api(tags = "后台管理系统[友链]")
@RequestMapping("/admin")
@RestController
public class FriendLinkController {

    @Autowired
    private FriendLinkService friendLinkService;

    @SystemLog(notes = "获取友链列表{后台管理系统}")
    @ApiOperation(value = "获取友链列表接口")
    @GetMapping("/links")
    public ResponseResult getLinks(@RequestParam("current")Integer current,
                                   @RequestParam("size")Integer size,
                                   @RequestParam(value = "keywords",required = false)String keywords)
    {
        return friendLinkService.getLinks(current,size,keywords);
    }


    @SystemLog(notes = "删除(物理)友链列表{后台管理系统}")
    @ApiOperation(value = "删除(物理)友链列表接口")
    @DeleteMapping("/links")
    public ResponseResult deleteFriendLinks(@RequestBody Integer[] linkIdList){
        return friendLinkService.deleteFriendLinks(linkIdList);
    }


    @SystemLog(notes = "添加或修改友链{后台管理系统}")
    @ApiOperation(value = "添加或修改友链接口")
    @PostMapping("/links")
    public ResponseResult updateLinks(@RequestBody FriendLink friendLink){
        return  friendLinkService.updateLinks(friendLink);
    }

}
